package com.jming.jike.enums;

import com.jming.jike.common.BusinessException;

/**
 * 菜品类型枚举
 *
 * @author jinming.zhang
 * @version 0.0.1
 * @date 2022/04/15
 */
public enum CategoryTypeEnum {

    /**
     * 菜品类型
     */
    DISHES_TYPE(1, "菜品类型"),
    /**
     * 套餐类型
     */
    SET_MEAL_TYPE(2, "套餐类型");

    private final Integer code;
    private final String desc;

    CategoryTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 检查类别
     *
     * @param type
     */
    public static void checkCategoryByType(Integer type) {

        for (CategoryTypeEnum categoryTypeEnum : CategoryTypeEnum.values()) {
            if (categoryTypeEnum.getCode().equals(type)) {
                return;
            }
        }

        throw new BusinessException("类型不正确!");
    }

}
